﻿namespace Jhong.FunMVCBlog
{
    using Microsoft.Owin.Builder;
    using System;
    using System.Collections.Generic;
    using System.Threading.Tasks;

    public class TinyFoxAdapter
    {
        public class Adapter
        {
            private static Func<IDictionary<string, object>, Task> _owinAppFunc;

            public Adapter()
            {
                var builder = new AppBuilder();
                var startup = new Startup();
                startup.Configuration(builder);
                _owinAppFunc = builder.Build();
            }

            public Task OwinMain(IDictionary<string, object> env)
            {
                if (_owinAppFunc == null) return null;

                return _owinAppFunc(env);
            }
        }
    }
}